<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./vue.js"></script>
</head>
<body>
  <div id="app">
    <home></home>
    <news></news>
  </div>
  <script>
    // 定义混入
    const mixin1 = {
      data(){
        return{
          msg:"hello"
        }
      },
      methods:{
        changeMsg(){
          this.msg = "改变啦"
        }
      },
      computed:{
        msg2(){
          return this.msg.split('').reverse().join('')
        }
      }
    }
    let Home = {
      template:`
        <div>
          home组件
          {{msg}}
          {{msg2}}
          <button @click="changeMsg">按钮</button>
        </div>
      `,
      data(){
        return {
         
        }
      },
      mixins:[mixin1]
    }
    let News = {
      template:`
        <div>
          news组件
          {{msg}}
        </div>
      `,
      mixins:[mixin1]
    }
    Vue.component('Home',Home);
    Vue.component('News',News);
    let vm = new Vue({
      el:"#app",
      data:{}
    })
  
  </script>
</body>
</html>